
#pragma once

#include <boost/scoped_ptr.hpp>
#include <memory>

#include <Ogre.h>

#include <OgreNewt.h>

#include "PhysWorld.h"


#include "GameState.h"
#include "CEGUIOwner.h"
#include "CameraControl.h"

#include "Caelum.h"


//! This class represents the state when the player is logged-in and in zone.
//! The game state itself.
//!
class InGameState : 
	public GameState, 
	public CEGUIOwner,
	private PhysWorld
{
	Ogre::SceneManager * mSceneMgr;
	Ogre::Camera * mCamera;
	Ogre::Viewport * mViewport;

	boost::scoped_ptr<CameraControl> mCameraControl;

	Ogre::SceneNode * mTowerNode;
	float mTowerScale;

	Ogre::Light * mSunLight;

	caelum::CaelumSystem * mCaelumSystem;

public:

	InGameState(GameManager & gameManager);

	void createScene();

	virtual const char * getStateName();

	//! When we enter the login screen. Initializes the login screen scene.
	//!
	virtual void enter();

	//! Creates the CEGUI menu.
	//!
	void createGUI();

	//! Called every frame.
	//!
	virtual bool frameStarted(Ogre::FrameEvent const & evt);

	//! When we exit the login screen and we don't intend to return soon. 
	//! We destroy it completely to save resources.
	virtual void exit();

	virtual void keyPressed(OIS::KeyEvent const & e);

	virtual void keyReleased(OIS::KeyEvent const & e);

	virtual bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);

	virtual bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);

	virtual bool mouseMoved(const OIS::MouseEvent &e);


	/* GUI events */


	//! Is called when the Exit button is pressed.
	//!
	bool OnGUIExit(const CEGUI::EventArgs & e);

	//! Is called when the Login button is pressed.
	bool OnGUILogin(const CEGUI::EventArgs & e);
};